package com.keke.select.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.keke.select.service.SelectService;

@WebServlet("/api/GetApplay")
public class GetApplay extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static SelectService service = new SelectService();

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("key");
		String type = req.getParameter("type");
		String result = null;
		if("0".equals(type))
			result = service.getApplayByCptt(id);//applays
		else if("1".equals(type))
			result = service.getApplayByUser(id);//ids
//		Boolean isGrouping = true;
//		System.out.println(applays.get(0).getGrouping());
//		if("null".equals(applays.get(0).getGrouping()))
//			isGrouping = false;
		
			
		PrintWriter out =  resp.getWriter();
		out.print(result);
	}

	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		return;
	}
}